/**
 * Created by wumu on 5/30/18.
 */

import * as request from '../../api/device'

const device = {
    actions:{
        //获取树级结构
        SelectDevice({ commit }, data) {
            return new Promise((resolve, reject) => {
                request.selectDevice(data).then((response) => {
                    resolve(response);
                }).catch(error => {
                    reject(error);
                });
            });
        },
        //获取开关设备
        GetSwitchList({ commit }, data) {
            return new Promise((resolve, reject) => {
                request.getSwitchList(data).then((response) => {
                    resolve(response);
                }).catch(error => {
                    reject(error);
                });
            });
        },
        //获取采集设备
        GetBuildCollection({ commit }, id) {
            return new Promise((resolve, reject) => {
                request.getBuildCollection(id).then((response) => {
                    resolve(response);
                }).catch(error => {
                    reject(error);
                });
            });
        },
        //获取开关统计数据
        GetSwitchStatistics({ commit }) {
            return new Promise((resolve, reject) => {
                request.getSwitchStatistics().then((response) => {
                    resolve(response);
                }).catch(error => {
                    reject(error);
                });
            });
        },
        //控制开关
        ControlSwitch({ commit },data) {
            return new Promise((resolve, reject) => {
                request.controlSwitch(data).then((response) => {
                    resolve(response);
                }).catch(error => {
                    reject(error);
                });
            });
        },
        //批量控制开关
        BatchControlSwitch({ commit },data) {
            return new Promise((resolve, reject) => {
                request.batchControlSwitch(data).then((response) => {
                    resolve(response);
                }).catch(error => {
                    reject(error);
                });
            });
        },
        BatchSwitch({ commit },data){
            return new Promise((resolve, reject) => {
                request.batchSwitch(data).then((response) => {
                    resolve(response);
                }).catch(error => {
                    reject(error);
                });
            });
        },
        //获取场景列表
        GetSceneList(){
            return new Promise((resolve,reject)=>{
                request.getSceneList().then((response)=>{
                    resolve(response);
                }).catch(error =>{
                    reject(error);
                })
            })
        },
        //删除场景
        DeleteScene({ commit },id){
            return new Promise((resolve,reject)=>{
                request.deleteScene(id).then((response)=>{
                    resolve(response)
                }).catch(error=>{
                    reject(error)
                })
            })
        },
        //添加场景
        AddScene({ commit },data){
            return new Promise((resolve,reject)=>{
                request.addScene(data).then((response)=>{
                    resolve(response)
                }).catch(error=>{
                    reject(error)
                })
            })
        },
        //更新场景
        UpdateScene({ commit },data){
            return new Promise((resolve,reject)=>{
                request.updateScene(data).then((response)=>{
                    resolve(response)
                }).catch(error=>{
                    reject(error)
                })
            })
        },
        //获取场景下的设备
        GetSceneSwitch({ commit },data){
            return new Promise((resolve,reject)=>{
                request.getSceneSwitch(data).then((response)=>{
                    resolve(response)
                }).catch(error=>{
                    reject(error)
                })
            })
        },
        //删除场景下的设备
        DeleteSceneSwitch({ commit },data){
            return new Promise((resolve,reject)=>{
                request.deleteSceneSwitch(data).then((response)=>{
                    resolve(response)
                }).catch(error=>{
                    reject(error)
                })
            })
        },
        //添加场景设备
        AddSceneSwitch({ commit },data){
            return new Promise((resolve,reject)=>{
                request.addSceneSwitch(data).then((response)=>{
                    resolve(response)
                }).catch(error=>{
                    reject(error)
                })
            })
        },
        //控制场景设备
        ControlSceneSwitch({ commit },data){
            return new Promise((resolve,reject)=>{
                request.controlSceneSwitch(data).then((response)=>{
                    resolve(response)
                }).catch(error=>{
                    reject(error)
                })
            })
        },
    }
}

export default device
